package Implementaciones;

import java.util.Random;

import TDA.ColaTDA;


public class Cola<E> implements ColaTDA<E>{
	class Elem<T>{
		T e;
		
		@Override
		public boolean equals(Object obj){
			return e.equals(obj);
		}
		
		@Override
		public String toString(){
			return e.toString();
		}
	}
	private Elem<E>[] elementos;
	private int cant;
	
	private Random random= new Random();
	
	public void acolar(E elem) {
		for (int i = cant; i > 0;i--){
			elementos[i] = elementos[i-1];
		}
		elementos[0] = new Elem<E>();
		elementos[0].e=elem;
		cant++;
	}


	public boolean colaVacia() {
		return cant==0;
	}


	public E primero() {
		return elementos[cant-1].e;
	}

	
	public void inicializarCola() {
		elementos=new Elem[1000];
		cant=0;
	}

	
	public void desacolar() {
		cant--;
	}
	
	public String toString(){
		String r = new String();
		for (int i=0; i<cant;i++){
			r+=elementos[i].toString();
			r+=", ";
		}
		if(r.length() > 0)
			r=r.substring(0,r.length()-2);
		return r;
	}
	
}
